var id;

$(function() {
  id = ly.getUrlParam("id");

  $(".form").getForm({
    id: id,
    type: "post",
    ajaxform: "true"
  }, function(data) {
    var listData = {
      "initData": { //默认参数配置
        "pageNum": "1",
        "pageSize": "10"
      },
      "url": site.apiUrl + "/back/feedback/findAll", // 数据请求url
      "type": "post",
      "ajaxform": "true",
      "checkname": "datachk",
      "col": [ //数据列
        { "field": "coverImg", "display": "用户头像", "fun": "changePic", "width": "1" },
        { "field": "feedbackUserName", "display": "用户名称" },
        { "field": "feedbackContext", "display": "评论内容" },
        { "field": "createAt", "display": "录入日期", "fun": "changeDate", "width": "2" }
      ]
    }
    $("#orderCommentList").getList(listData);
  });
});

// 设置默认图片
function changePic(v, o, d) {
  if (d.coverImg != null && d.coverImg != '') {
    $(o).html("<img src=" + d.coverImg + " width='30' height='30'>");
  } else {
    $(o).html("<img src='" + site.interUrl + "/img/default_head.jpg' width='30' height='30'>");
  }
}

// 时间戳转换时间
function changeDate(v, o, d) {
  var baseDateTime;
  var timestamp = new Date(d.createTime);
  baseDateTime = timestamp.toLocaleDateString().replace(/\//g, "-") + " " + timestamp.toTimeString().substr(0, 8)
  if (d.createTime != null && d.createTime != '') {
    $(o).html(baseDateTime)
  }
}
